<?php slot('header')?>

<style type="text/css">
<!-- 
div.box-content-main table.table-list td.number{
	width: 100px;
}
-->
</style>
<script type="text/javascript">
	function setHome(data){
		$data = $.parseJSON(data);
		ERROR.hide();
		ERROR.clear();
		$('a[data-id='+$data.id+'] > img').attr('src',parseInt($data.val, 10)==0?'/css/admin/img/global/home.png':'/css/admin/img/global/home-active.png');
		$('a[data-id='+$data.id+']').attr('data-value',parseInt($data.val, 10)==0?'1':'0');
	}
</script>
<?php end_slot()?>
<div class="box-navigation">
	<?php echo $data['navigation']?>
</div>
<div class="clr"></div>
<?php include_component('default', 'error');?>
<div class="clr"></div>
<div class="box-filter">
	<form action="<?php echo $data['filter_action']?>" method="get" name="filter_form" id="filter-form">
		<select name="filter[filter_cate_id]" id="filter-cate-id" class="combo-box hz-selected" data-selected="<?php echo $data['filter']['filter_cate_id']?>">
			<option value="-1"><?php echo __('select-option-all')?></option>
			<?php foreach ($data['filter']['cates'] as $al):?>
			<option value="<?php echo $al['id']?>"><?php echo $al['name']?></option>
			<?php endforeach?>
		</select>
		<select name="filter[filter_product_manufacturer_id]" id="filter-product-manufacturer-id" class="combo-box hz-selected" data-selected="<?php echo $data['filter']['filter_product_manufacturer_id']?>">
			<option value="-1"><?php echo __('select-option-all')?></option>
			<?php foreach ($data['filter']['manufacturers'] as $al):?>
			<option value="<?php echo $al['id']?>"><?php echo $al['name']?></option>
			<?php endforeach?>
		</select>
		<select name="filter[filter_os_environment_id]" id="filter-os-environment-id" class="combo-box hz-selected" data-selected="<?php echo $data['filter']['filter_os_environment_id']?>">
			<option value="-1"><?php echo __('select-option-all')?></option>
			<?php foreach ($data['filter']['os'] as $al):?>
			<option value="<?php echo $al['id']?>"><?php echo $al['name']?></option>
			<?php endforeach?>
		</select>
		<select name="filter[filter_class_id]" id="filter-class-id" class="combo-box hz-selected" data-selected="<?php echo $data['filter']['filter_class_id']?>">
			<option value="-1"><?php echo __('select-option-all')?></option>
			<?php foreach ($data['filter']['classes'] as $al):?>
			<option value="<?php echo $al['id']?>"><?php echo $al['name']?></option>
			<?php endforeach?>
		</select>
		<select name="filter[filter_level_id]" id="filter-level-id" class="combo-box hz-selected" data-selected="<?php echo $data['filter']['filter_level_id']?>">
			<option value="-1"><?php echo __('select-option-all')?></option>
			<?php foreach ($data['filter']['levels'] as $al):?>
			<option value="<?php echo $al['id']?>"><?php echo $al['name']?></option>
			<?php endforeach?>
		</select>
		<select name="filter[filter_enabled]" id="filter-enable" class="combo-box hz-selected" data-selected="<?php echo $data['filter']['filter_enabled']?>">
			<option value="-1"><?php echo __('select-option-all')?></option>
			<option value="0"><?php echo __('is-enabled-0')?></option>
			<option value="1"><?php echo __('is-enabled-1')?></option>
		</select>
		<input type="text" class="hz-data-sample" maxlength="255" name="filter[filter_key]" id="filter-key" value="<?php echo $data['filter']['filter_key']?>" data-sample="<?php echo __('filter-sample')?>"/>
		<input type="button" name="filter[filter_submit]" id="filter_submit" class="button hz-filter-submit" data-form-id="filter-form" data-keysearch-id="filter-key" value="<?php echo __('filter-submit')?>"/>
	</form>
</div>
<div class="clr"></div>
<div class="box-content">
	<form action="<?php echo $data['filter_action']?>" method="post" name="form_main" id="form-main">
		<input type="hidden" value="none" name="action_name" id="action-name"/>
		<div class="control">
			<a href="#" class="hz-control-get add" data-action="<?php echo ADMIN_DEFINED::ADD_RECORD?>" ><?php echo __('control-add')?></a>
			<a href="#" class="hz-control delete" data-action="<?php echo ADMIN_DEFINED::DELETE_RECORD?>" hz-require="selected" hz-confirm="confirm" data-confirm="<?php echo __('confirm-delete')?>"><?php echo __('control-delete')?></a>
			<a href="#" class="hz-control enable" data-action="<?php echo ADMIN_DEFINED::ENABLE?>" hz-require="selected"><?php echo __('control-enable')?></a>
			<a href="#" class="hz-control disable" data-action="<?php echo ADMIN_DEFINED::DISABLE?>" hz-require="selected"><?php echo __('control-disable')?></a>
			<a href="#" class="hz-control save-order" data-action="<?php echo ADMIN_DEFINED::SAVE_ORDER?>" ><?php echo __('control-save-order')?></a>
		</div>
		<div class="clr"></div>
		<div class="box-content-main">
			<table class="table-list" cellspacing="0" cellpadding="0" border="0">
				<tr>
					<td class="head checkbox-select"><input type="checkbox" name="select_checkall" id="select-checkall" title="<?php echo __('to-checkall')?>" class="chk-select chk-checkall"/></td>
					<td class="head title"><?php echo __('product-name')?></td>
					<td class="head number"><?php echo __('product-photo')?></td>
					<td class="head number"><?php echo __('product-cate-title')?></td>
					<td class="head sort-order"><?php echo __('sort-order')?></td>
					<td class="head updated-at"><?php echo __('updated-at')?></td>
					<td class="head action"><?php echo __('list-action')?></td>
				</tr>
				<?php 
				$count_for = 0;
				foreach($data['list'] as $val):
					$cate = ProductCates::getDataByIdAdmin($val['cate_id']);
					$os = OsEnvironments::getDataByIdAdmin($val['os_environment_id']);
				//print_r($os);
				?>
				<tr class="class<?php echo ++$count_for%2?> enable-<?php echo intval($val['is_enabled'])?>">
					<td class="checkbox-select"><input type="checkbox" name="select_list[]" class="checkbox-select" value="<?php echo $val['id']?>" id="select_<?php echo $val['id']?>" title="<?php echo __('to-check')?>" /></td>
					<td class="title">
						<a href="#" class="hz-control-get edit" data-action="<?php echo ADMIN_DEFINED::EDIT_RECORD?>&id=<?php echo $val['id']?>" data-require="none">
							<?php echo $val['name']?>
							<br/><span style="font-style: italic;">(<?php echo $val['sub_name']?>)</span>
						</a>	
					</td>
					
					<td class="img">
							<?php if(!empty($val['photo_url'])):?>
							<img src="<?php echo $val['photo_url']?>" class="thumb"/>
							<?php endif?>
					</td>
					<td class="img">
							<?php echo $cate['ProductCatesI18n'][$sf_user->getCulture()]['name'],'<br/>', $os['OsEnvironmentsI18n'][$sf_user->getCulture()]['name']?>
					</td>
					<td class="sort-order">
						<input type="text" data-require="number-only" name="sort_orders[]" class="sort-order" value="<?php echo $val['sort_order']?>"/>
						<input type="hidden" name="ids[]" value="<?php echo $val['id']?>"/>
					</td>
					
					<td class="updated-at"><?php echo DateHelper::dateFormat($val['updated_at'])?></td>
					<td class="action">
						<a href="#" class="hz-control-get edit"  data-action="<?php echo ADMIN_DEFINED::EDIT_RECORD ?>&id=<?php echo $val['id']?>" title="<?php echo __('action-edit')?>" alt="<?php echo __('action-edit')?>" class="column-action"><img src="/css/admin/img/global/edit.png"/></a>
						<a href="#" class="hz-control-ajax" data-url="?" data-action="<?php echo ADMIN_DEFINED::SET_HOME ?>" data-id="<?php echo $val['id']?>" data-value="<?php echo intval($val['is_hot'])?'0':'1'?>" callback-after-success="setHome" title="<?php echo __('album-set-home')?>" alt="<?php echo __('album-set-home')?>" class="column-action"><img src="/css/admin/img/global/home<?php echo intval($val['is_hot'])?'-active':''?>.png"/></a>
					</td>
				</tr>
				<?php endforeach;?>
			</table>
		</div>
		<div class="clr"></div>
		<div class="control">
			<a href="#" class="hz-control-get add" data-action="<?php echo ADMIN_DEFINED::ADD_RECORD?>" ><?php echo __('control-add')?></a>
			<a href="#" class="hz-control delete" data-action="<?php echo ADMIN_DEFINED::DELETE_RECORD?>" hz-require="selected" hz-confirm="confirm" data-confirm="<?php echo __('confirm-delete')?>"><?php echo __('control-delete')?></a>
			<a href="#" class="hz-control enable" data-action="<?php echo ADMIN_DEFINED::ENABLE?>" hz-require="selected"><?php echo __('control-enable')?></a>
			<a href="#" class="hz-control disable" data-action="<?php echo ADMIN_DEFINED::DISABLE?>" hz-require="selected"><?php echo __('control-disable')?></a>
			<a href="#" class="hz-control save-order" data-action="<?php echo ADMIN_DEFINED::SAVE_ORDER?>" ><?php echo __('control-save-order')?></a>
		</div>
		<?php if(count($data['pagination_pager'])>1):?>
		<div class="pagination">
			<span><?php echo __('pagination-text')?></span>
			<span class="pagination"> 
			<?php foreach ($data['pagination_pager'] as $p):?>
				<a href="<?php echo empty($p['url'])?'#':($data['app_prefix'].$p['url'])?>" class="<?php echo $p['page_class']?>"><?php echo $p['page_num']?></a>
			<?php endforeach;?>
			</span>
			<div class="clr"></div>
		</div>
		<?php endif;?>
		<div class="clr"></div>
	</form>
</div>